package TCP;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        //创建服务端，并指定端口号
        ServerSocket serverSocket = new ServerSocket(8888);

        //等待客户端发送消息来获取管道对象
        Socket socket = serverSocket.accept();
        //通过管道对象再来获取到读取流对象
        InputStream inputStream = socket.getInputStream();
        //再将低级流转化为高级流
        DataInputStream dis = new DataInputStream(inputStream);
        String s = dis.readUTF();
        System.out.println(s);

        //关闭资源
        dis.close();
        socket.close();

    }
}
